# # coding=utf-8
import string
import random
import xlrd
#最大行数100万
import time

import openpyxl

outwb = openpyxl.Workbook()
# outwb = load_workbook("../../项目文件\期初120211206182821.xlsx")
# outwb = openpyxl.load_workbook("../../项目文件\期初120211206182821.xlsx")
outws = outwb.create_sheet(index=0)

gm1 = salt = ''.join(random.sample(string.ascii_letters + string.digits, 8))
name = '商品'
gc = '0804503000'
dcl_unit = '007'
ma = 'I'
del_num = string.digits
total = ''.join(random.sample(string.digits, 8))
bz = '110'
ck = ''.join(random.sample(string.digits, 5))
kw = ''.join(random.sample(string.ascii_letters + string.digits, 4))

outws.cell(1, 1, str("企业期初库存#"))
outws.cell(2, 1, str("企业十位数编码"))
outws.cell(2, 2, str("企业名称"))
outws.cell(2, 3, str("企业信用代码"))
outws.cell(2, 4, str("统计日期"))
outws.cell(2, 5, str("组织id"))
outws.cell(3, 1, str("142GFDFGDH"))
outws.cell(3, 2, str("企业name"))
outws.cell(3, 3, str("ABCDEFG"))
outws.cell(3, 4, str(time.strftime('%Y%m%d%H%M%S')))
outws.cell(3, 5, str("103061"))
outws.cell(4, 1, str("企业期初库存#明细"))
outws.cell(5, 1, str("料号"))
outws.cell(5, 2, str("商品名称"))
outws.cell(5, 3, str("商品编码"))
outws.cell(5, 4, str("计量单位"))
outws.cell(5, 5, str("料件成品标志"))
outws.cell(5, 6, str("数量"))
outws.cell(5, 7, str("总价"))
outws.cell(5, 8, str("币制"))
outws.cell(5, 9, str("仓库号"))
outws.cell(5, 10, str("库位号"))

j = 1
m = 30
for i in range(0, m):
    try:
        # wr_sheet.write(i+1, 0, str("%s" % j))  # 所用账号
        outws.cell(i + 6, 1, str("%s" % ''.join(random.sample(string.ascii_letters + string.digits, 8))))
        outws.cell(i + 6, 2, str("%s" % name))
        outws.cell(i + 6, 3, str("%s" % gc))
        outws.cell(i + 6, 4, str("%s" % dcl_unit))
        outws.cell(i + 6, 5, str("%s" % ma))
        outws.cell(i + 6, 6, str("%s" % ''.join(random.sample(string.digits, 5))))
        outws.cell(i + 6, 7, str("%s" % ''.join(random.sample(string.digits, 8))))
        outws.cell(i + 6, 8, str("%s" % bz))
        outws.cell(i + 6, 9, str("%s" % ''.join(random.sample(string.digits, 5))))
        outws.cell(i + 6, 10, str("%s" % ''.join(random.sample(string.ascii_letters + string.digits, 4))))
        print("写入。。。。%s" % j)
        j += 1
        # if i in (100000, 200000, 300000):
        #     outwb.save("../../项目文件\期初%1s.xlsx" % time.strftime('%Y%m%d%H%M%S'))
    except Exception as E:
        outwb.save("../../项目文件\期初%1s.xlsx" % time.strftime('%Y%m%d%H%M%S'))
        print("%s写入失败：%S" % str(i), E)

outws.cell(m + 6, 1, str("END#"))
outwb.save("../../项目文件\期初1%s.xlsx" % time.strftime('%Y%m%d%H%M%S'))
outwb.close()

